package com.cvpoc.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.web.struts.DispatchActionSupport;

import com.cvpoc.exception.BusinessException;
import com.cvpoc.struts.form.LoginForm;

public class LoginAction extends DispatchActionSupport {
	
	public ActionForward identificationFormUtilisateur(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		return mapping.findForward("successIdentificationFormUtilisateur");
		
	}
	
	public ActionForward identificationLoginUtilisateur(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		LoginForm loginForm = (LoginForm) form;
		
		if (loginForm.getNomUtilisateur().equals(loginForm.getPasseUtilisateur())) {
			return mapping.findForward("successIdentificationLoginUtilisateur");
		} else {
			return mapping.findForward("failureIdentificationLoginUtilisateur");
		}
	}
	
	public ActionForward identificationLogoutUtilisateur(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		return mapping.findForward("successIdentificationLogoutUtilisateur");
	}	

}
